#include "Matrix.h"

#ifndef __globals_h__
#define __globals_h__

// tolerances and common numbers

double _EPS = 2.2e-16;
double _PI = 3.14159265358979;
int UpdateNodes = 10;

// domain variables

double Xleft;
double Xright;
double Ybottom;
double Ytop;
double dx;
double dy;
double dt;
int Xnodes;
int Ynodes;
Matrix X;
Matrix Y;
Matrix Phi;
Matrix PhiNecrotic;
Matrix PhiQuiescent;

// these are provided by the tumor module

Matrix Oxygen;
Matrix Pressure;
Matrix OutPressure;
Matrix MDE;
Matrix MDEdiffusivity;
Matrix ECM;
Matrix TAF;
Matrix Mobility;
Matrix Structure;

// these are provided by angiogenesis needed when resume data

Matrix OxygenSource; 

Matrix BloodVesselIndicator;
Matrix BloodVesselRadius;
Matrix Flow;
Matrix BloodVesselPressureX;
Matrix BloodVesselPressureY;
Matrix InterPressure;
//Matrix OsmoticDif;
Matrix CellColor;
Matrix LymIndicator;
Matrix Permeability;
Matrix WallGradient;
Matrix Conduct;
Matrix HaematocritLevel;
Matrix SproutTips;
Matrix VesselCells;
Matrix MapIndicator;
Matrix MapVesselCells;
Matrix MapSproutTips;
Matrix MapFlow;
Matrix MapRadius;
Matrix MapPressure;
Matrix Shuffle;
Matrix VEGFR;
Matrix Notch;
Matrix Delta4;
Matrix Tracer;
Matrix TracerX;
Matrix TracerY;
Matrix Leak;
Matrix CollapseClock;
Matrix Drainage;
Matrix TotalPressure;
Matrix TracerS;
Matrix TracerT;
Matrix TracerD;
Matrix Debuger;
Matrix Macrof;
Matrix MacrofD;
Matrix SrtX;
Matrix SrtY;
Matrix ShearRate;
Matrix Wss;
Matrix Stability;
Matrix PreExist;

Matrix BloodVesselRadiusXdir;
Matrix BloodVesselRadiusYdir;
Matrix BloodVesselIndicatorX;
Matrix BloodVesselIndicatorY;
Matrix Svar;
Matrix Swss;
Matrix Sp;
Matrix Sm;
Matrix Ss;
Matrix SvarX;
Matrix SwssX;
Matrix SpX;
Matrix SmX;
Matrix SsX;
Matrix SvarY;
Matrix SwssY;
Matrix SpY;
Matrix SmY;
Matrix SsY;
Matrix HomPressure;
Matrix SproutAge;
Matrix VesselAge;
Matrix TaxisJump;
Matrix AdvectConstant;
//these are not output, but convenient to treat as global


Matrix BloodNodePressure;
Matrix ConductX;
Matrix ConductY;

Matrix FlowX;
Matrix FlowY;
Matrix VisX;
Matrix VisY;
Matrix Vis;
Matrix WssX;
Matrix WssY;


Matrix Coeffecient;
Matrix TempPressure;
Matrix OneDPosition;



// data information 

char SaveDirectory [1025];
char* ParameterFile = "TumorAngiogenesis.cfg";
char* LogFile = "logfile.txt";
char Xfile [1025];
char Yfile [1025];
char PhiFile [1025];
char PhiNecroticFile [1025];
char PhiQuiescentFile [1025];
char OxygenFile [1025];
char OxygenDiffusivityFile [1025];
char PressureFile [1025];
char MobilityFile [1025];
char ECM_File [1025];
char Original_ECM_File [1025];
char MDEfile [1025];
char TAFfile [1025];
char TumorParameterFile [1025];
char BloodNodePressureFile [1025];
char InterPressureFile [1025];
char BloodVesselIndicatorFile [1025];
char BloodVesselIndicatorXFile [1025];
char BloodVesselIndicatorYFile [1025];
char SproutTipsFile [1025];
char StructureFile [1025];
char BloodVesselDensityFile [1025];
char HaematocritLevelFile [1025];
char SproutAgeFile [1025];
char VesselAgeFile [1025];
char BloodVesselRadiusXdirFile [1025];
char BloodVesselRadiusYdirFile [1025];
char BloodVesselRadiusFile [1025];
char ConductXFile [1025];
char ConductYFile [1025];
char VisXFile [1025];
char VisYFile [1025];
char VisFile [1025];
char BloodVesselPressureXFile [1025];
char BloodVesselPressureYFile [1025];

char CellColorFile[1025];

char LymIndicatorFile [1025];
char PermeabilityFile [1025];
char WallGradientFile [1025];
char ConductFile [1025];

bool ResumeFromPreviousData; 
bool InitializeSimulationFromPictures;
char TumorPictureFile [1025];
char TissuePictureFile [1025];
char TissueTypesFile [1025];
bool ScratchSpaceMode;
double MicronsPerPixel;
double MicronsPerDeltaX;
double DiffusionLengthScaleInMicrons;

double MaxMobility;

// time information 

double t;
double SimulationStartTime;
double SimulationEndTime;
double OutputInterval;
double NextOutputTime; 
bool MinimalSaveMode;
double waterpressureA;
double vesselpressureA;
double hompressureA;
Matrix InitialPhi;


char* StringBuffer;
int StringBufferLength = 2049;

// oxygen globals

double TumorOxygenUptakeRate;
double QuiescentOxygenUptakeRate;
double NecroticOxygenUptakeRate;
double ECMoxygenUptakeRate;
Matrix OxygenDiffusivity;
double ExteriorOxygenDiffusivity;
// double MaxOxygenDeliveryRate;

double QuiescenceOxygenLevel;
double NecrosisOxygenLevel;
bool IsFirstOxygenUpdate;

double bulk_blood_tissue_transfer_rate;
double bulk_blood_transfer_cutoff_distance; 
Matrix BloodVesselDensity;

bool TopBloodVessel;
bool BottomBloodVessel;

bool FunctionalMobility;
double ECMtaxisConstant;
double Kwall1;
double Kwall2;
double reflect;
double Lym;
double LymPressure;

double Hom;
double Hom_o;

double Perm;
double Perm_o;
double CondTissue;
double CondTissue_o;


double PLmin;
double PLmax;
double KLmax;
double Pmin;
double Pmax;


double WaterPressureMin;
double VFWater;
double VFCell;
double ChMobility;
double ChLength;
double MitosisRate;

double AdvectionConstant;
double FunctionSmoothingLevel;

// tumor growth globals
double ApoptosisRate;        // A in all papers
double TumorAggressivenessG; // G in all papers
double TumorNecrosisRateGN;  // GN in all papers 
double DRG_Effect;
// pressure globals

double TumorProliferationConstant; // b in the paper
double TumorSurfaceTensionConstant;
double ExteriorMobility;

Matrix Speed;
Matrix NecroticSpeed;
Matrix PressureGradientX;
Matrix PressureGradientY;
Matrix ECMgradientX;
Matrix ECMgradientY;
Matrix ECMtaxisCoefficient;
Matrix NormalX;
Matrix NormalY;

Matrix GlobalMatrix;

// ECM globals;

double ECM_DegradationConstant;
double ECM_ProductionConstant;
double MinimumECM;
double MaximumECM;
double MinimumMobility;
double MaximumMobility;
double MobilityECM_ParameterA;
double MobilityECM_ParameterB;

// TAF globals;

double TAFdiffusionConstant;
double TAFprodctionConstant;
double TAFdecayConstant;

double EndothelialTAFuptakeRate;

// MDE globals;

double MDEdiffusionConstant;
double MaxMDEdiffusionConstant;
double MDEprodctionConstant;
double MDEdecayConstant;
double MDE_DegradationConstant;

double D_DRG;
double D_DRG_T;
double DRGprodctionConstant;
double DRGdecayConstant;
double DRG_DegradationConstant;
double DRGDecayVessel;

// angiogenesis globals;
int innumbers, outnumbers;
bool Injectionrandomized;
bool FlowBegin;
bool TumorBegin;
bool AdaptionBegin;
bool ResetPressure;
double BloodTissueTransferRate;
double Oxygen_pi;
double OxygenUptakeRate;
double AngiogenesisTriggeringThreshold;
double AngioDeltaT;
double Custom_Cutoff_Max;
double Custom_Cutoff_Max_New;
double collapseConstant;
double collapseConstant_New;
double AngioGrowthInterval;
double AngioTime;
double FlowDuration;
double GrowthDuration;
double TotalIn;
double TracerMax;
double FlowMax;

#endif
